CREATE TABLE  "GEOFT_DNAEE_BACIA" 
   (	"DNB_CD" NUMBER(38,0) CONSTRAINT "HSYS_C0031824" NOT NULL ENABLE, 
	"DNB_NM" VARCHAR2(100), 
	"DNB_GM_POLIGONO" VARCHAR2(4000), 
	 CONSTRAINT "HSYS_C0031825" PRIMARY KEY ("DNB_CD") ENABLE
   )
/
CREATE TABLE  "GEOFT_DNAEE_SUBBACIA" 
   (	"DNS_CD" NUMBER(38,0) CONSTRAINT "HSYS_C0031826" NOT NULL ENABLE, 
	"DNS_NM" VARCHAR2(100), 
	"DNS_GM_POLIGONO" VARCHAR2(4000), 
	"DNB_CD" NUMBER(38,0), 
	"DNS_NU_SUBBACIA" NUMBER(38,0) NOT NULL ENABLE, 
	 CONSTRAINT "HSYS_C0031827" PRIMARY KEY ("DNS_CD") ENABLE, 
	 CONSTRAINT "HSYS_C0031852" FOREIGN KEY ("DNB_CD")
	  REFERENCES  "GEOFT_DNAEE_BACIA" ("DNB_CD") ENABLE
   )
/
CREATE TABLE  "GEOFT_UNIDADE_FEDERACAO" 
   (	"UFD_CD" NUMBER(38,0) CONSTRAINT "HSYS_C0031836" NOT NULL ENABLE, 
	"UFD_RPA_CD" NUMBER(38,0), 
	"UFD_CD_IBGE" VARCHAR2(2), 
	"UFD_NM" VARCHAR2(100), 
	"UFD_SG" VARCHAR2(5), 
	"UFD_AR_KM2" NUMBER(10,2), 
	"UFD_QT_POPULACAO" NUMBER(10,0), 
	"UFD_GM_POLIGONO" VARCHAR2(4000), 
	 CONSTRAINT "HSYS_C0031844" PRIMARY KEY ("UFD_CD") ENABLE, 
	 CONSTRAINT "HSYS_C0042178" FOREIGN KEY ("UFD_RPA_CD")
	  REFERENCES  "GEOFT_PAIS" ("PAI_CD") ENABLE
   )
/
CREATE TABLE  "GEOFT_MUNICIPIO" 
   (	"MUN_CD" NUMBER(38,0) CONSTRAINT "HSYS_C0031828" NOT NULL ENABLE, 
	"MUN_CD_IBGE" VARCHAR2(17), 
	"MUN_NM" VARCHAR2(100), 
	"MUN_SG" VARCHAR2(5), 
	"MUN_AR_TOTAL_KM2" NUMBER, 
	"MUN_QT_POPULACAO" NUMBER(10,0), 
	"MUN_GM_POLIGONO" VARCHAR2(4000), 
	"MUN_MIC_CD" NUMBER(38,0), 
	"MUN_AR_URBANA_KM2" NUMBER(10,2), 
	"MUN_AR_RURAL_KM2" NUMBER(10,2), 
	"MUN_DT_EMANCIPACAO" DATE, 
	"MUN_AA_REFERENCIA" NUMBER(4,0), 
	"MUN_NM_MUNICIPIO_ORIGEM" VARCHAR2(200), 
	"UFD_CD" NUMBER(38,0), 
	 CONSTRAINT "HSYS_C0031830" PRIMARY KEY ("MUN_CD") ENABLE, 
	 CONSTRAINT "HSYS_C0031853" FOREIGN KEY ("UFD_CD")
	  REFERENCES  "GEOFT_UNIDADE_FEDERACAO" ("UFD_CD") ENABLE
   )
/
CREATE TABLE  "GEOFT_PAIS" 
   (	"PAI_CD" NUMBER(38,0) CONSTRAINT "HSYS_C0031831" NOT NULL ENABLE, 
	"PAI_CON_CD" NUMBER(38,0) CONSTRAINT "HSYS_C0031832" NOT NULL ENABLE, 
	"PAI_NM" VARCHAR2(100), 
	"PAI_SG" VARCHAR2(20), 
	"PAI_CD_ISO_3166" VARCHAR2(20), 
	"PAI_AR_KM2" NUMBER(13,2), 
	"PAI_QT_POPULACAO" NUMBER(10,0), 
	"PAI_GM_POLIGONO" VARCHAR2(4000), 
	 CONSTRAINT "HSYS_C0031833" PRIMARY KEY ("PAI_CD") ENABLE
   )
/
CREATE TABLE  "GEOFT_RIO" 
   (	"RIO_CD" NUMBER(10,0) CONSTRAINT "HSYS_C0031834" NOT NULL ENABLE, 
	"RIO_ID" NUMBER(38,0), 
	"RIO_NM_LIGACAO" VARCHAR2(255), 
	"RIO_NM" VARCHAR2(255), 
	"RIO_NM_COMPLETO" VARCHAR2(255), 
	"RIO_DI_RIO_KM" NUMBER(10,3), 
	"RIO_DI_FOZ_KM" NUMBER(10,3), 
	"RIO_CR_LONG_DE" NUMBER(9,7), 
	"RIO_CR_LAT_DE" NUMBER(9,7), 
	"RIO_CR_LONG_PARA" NUMBER(9,7), 
	"RIO_CR_LAT_PARA" NUMBER(9,7), 
	"RIO_DT_ATUALIZACAO" DATE, 
	"RIO_AA" NUMBER(4,0), 
	"RIO_ES" VARCHAR2(255), 
	"RIO_FO" VARCHAR2(255), 
	"RIO_GM_LINHA" VARCHAR2(4000), 
	 CONSTRAINT "HSYS_C0031835" PRIMARY KEY ("RIO_CD") ENABLE
   )
/
CREATE TABLE  "HDRTB_SUBBACIA_RIO" 
   (	"SBR_ID" NUMBER(19,0) CONSTRAINT "HSYS_C0031850" NOT NULL ENABLE, 
	"SBR_RIO_CD" NUMBER(19,0), 
	"SBR_DNS_CD" NUMBER(19,0), 
	 CONSTRAINT "HSYS_C0031851" PRIMARY KEY ("SBR_ID") ENABLE, 
	 CONSTRAINT "HSYS_C0031860" FOREIGN KEY ("SBR_DNS_CD")
	  REFERENCES  "GEOFT_DNAEE_SUBBACIA" ("DNS_CD") ENABLE, 
	 CONSTRAINT "HSYS_C0034711" FOREIGN KEY ("SBR_RIO_CD")
	  REFERENCES  "GEOFT_RIO" ("RIO_CD") ENABLE
   )
/
CREATE TABLE  "QLTTB_TIPO_CONTATO" 
   (	"TPC_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"TPC_DESCRICAO" VARCHAR2(255), 
	 CONSTRAINT "QLTTB_TIPO_CONTATO_PK" PRIMARY KEY ("TPC_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_TIPO_ENTIDADE" 
   (	"TPE_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"TPE_NM" VARCHAR2(60) NOT NULL ENABLE, 
	 CONSTRAINT "QLTTB_TIPO_ENTIDADE_PK" PRIMARY KEY ("TPE_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_CONTATO" 
   (	"CON_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"CON_TX_DESC" VARCHAR2(255), 
	"CON_TPC_ID" NUMBER(19,0), 
	"CON_REGISTRO_ID" NUMBER(19,0), 
	"CON_TPE_ID" NUMBER(19,0), 
	 CONSTRAINT "QLTTB_CONTATO_PK" PRIMARY KEY ("CON_ID") ENABLE, 
	 CONSTRAINT "QLTTB_TIPO_CONTATO_FK1" FOREIGN KEY ("CON_TPC_ID")
	  REFERENCES  "QLTTB_TIPO_CONTATO" ("TPC_ID") ENABLE, 
	 CONSTRAINT "QLTTB_TIPO_ENTIDADE_FK1" FOREIGN KEY ("CON_TPE_ID")
	  REFERENCES  "QLTTB_TIPO_ENTIDADE" ("TPE_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_TIPO_DOCUMENTO" 
   (	"TPD_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"TPD_DESCRICAO" VARCHAR2(100), 
	 CONSTRAINT "QLTTB_TIPO_DOCUMENTO_PK" PRIMARY KEY ("TPD_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_TIPO_OPERACAO" 
   (	"TPO_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"TPO_DESCRICAO" VARCHAR2(100), 
	 CONSTRAINT "QLTTB_TIPO_OPERACAO_PK" PRIMARY KEY ("TPO_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_USINA" 
   (	"USI_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"USI_NM" VARCHAR2(100) NOT NULL ENABLE, 
	"USI_NU_AREA_DRENAGEM" NUMBER(38,7), 
	"USI_NU_AREA_INCREMENTAL" NUMBER(38,7), 
	"USI_NU_AREA_INUNDADA" NUMBER(38,7), 
	"USI_NU_POTENCIA" NUMBER(38,7), 
	"USI_LATITUDE" NUMBER(38,7), 
	"USI_LONGITUDE" NUMBER(38,7), 
	"USI_DNS_CD" NUMBER(19,0), 
	"USI_TPU_ID" NUMBER(19,0), 
	"USI_DTA_PROJETO" TIMESTAMP (6), 
	"USI_PROCESSO" VARCHAR2(20), 
	"USI_ATO_LEGAL" VARCHAR2(20), 
	"USI_SITUACAO" VARCHAR2(20), 
	"USI_TX_OBSERVACOES" VARCHAR2(4000), 
	"USI_TX_ENDERECO" VARCHAR2(4000), 
	"USI_MUN_CD" NUMBER(38,0), 
	"USI_TX_CEP" VARCHAR2(8), 
	"USI_UFD_CD" NUMBER(38,0), 
	 CONSTRAINT "QLTTB_USINA_PK" PRIMARY KEY ("USI_ID") ENABLE, 
	 CONSTRAINT "QLTTB_USINA_TPU_IDC" FOREIGN KEY ("USI_TPU_ID")
	  REFERENCES  "QLTTB_TIPO_USINA" ("TPU_ID") ENABLE, 
	 CONSTRAINT "QLTTB_USINA_DNS_CDC" FOREIGN KEY ("USI_DNS_CD")
	  REFERENCES  "GEOFT_DNAEE_SUBBACIA" ("DNS_CD") ENABLE
   )
/
CREATE TABLE  "QLTTB_CONTROLE_DOCUMENTO" 
   (	"CDO_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"CDO_USI_ID" NUMBER(19,0), 
	"CDO_TPD_ID" NUMBER(19,0), 
	"CDO_TPO_ID" NUMBER(19,0), 
	"CDO_BOL_OBRIGATORIO" NUMBER(1,0), 
	"CDO_DTA_HORA" TIMESTAMP (6), 
	 CONSTRAINT "QLTTB_CONTROLE_DOCUMENTO_PK" PRIMARY KEY ("CDO_ID") ENABLE, 
	 CONSTRAINT "QLTTB_TIPO_DOCUMENTO_FK1" FOREIGN KEY ("CDO_TPD_ID")
	  REFERENCES  "QLTTB_TIPO_DOCUMENTO" ("TPD_ID") ENABLE, 
	 CONSTRAINT "QLTTB_TIPO_OPERACAO_FK1" FOREIGN KEY ("CDO_TPO_ID")
	  REFERENCES  "QLTTB_TIPO_OPERACAO" ("TPO_ID") ENABLE, 
	 CONSTRAINT "QLTTB_USINA_FK1" FOREIGN KEY ("CDO_USI_ID")
	  REFERENCES  "QLTTB_USINA" ("USI_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_STATUS_REGISTRO" 
   (	"STR_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"STR_NM" VARCHAR2(100), 
	"STR_DS" VARCHAR2(4000), 
	 CONSTRAINT "QLTTB_STR_PK" PRIMARY KEY ("STR_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_ESTACAO" 
   (	"EST_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"EST_NM" VARCHAR2(100) NOT NULL ENABLE, 
	"EST_CD_PLU" VARCHAR2(8), 
	"EST_CD_FLU" VARCHAR2(8), 
	"EST_IC_CAMPANHA" NUMBER(1,0) NOT NULL ENABLE, 
	"EST_CD_ADICIONALESTADO" NUMBER(10,0), 
	"EST_STR_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"EST_CD_IGPONTOPOLIGONO" NUMBER(19,0), 
	"EST_CD_IGPONTOLINHA" NUMBER(19,0), 
	"EST_CD_IGGEOMETRIA" NUMBER(19,0), 
	"EST_RES_ID" NUMBER(19,0), 
	"EST_IC_BASICA" NUMBER(1,0), 
	"EST_IC_ENERGETICA" NUMBER(1,0), 
	"EST_IC_NAVEGACAO" NUMBER(1,0), 
	"EST_TCA_ID" NUMBER(19,0), 
	"EST_TQC_ID" NUMBER(19,0), 
	"EST_CD_ADICIONAL_PLU" VARCHAR2(255), 
	"EST_CD_ADICIONAL_FLU" VARCHAR2(255), 
	 CONSTRAINT "SYS_C004159" PRIMARY KEY ("EST_ID") ENABLE, 
	 CONSTRAINT "QLTTB_ESTACAO_EST_STR_IDC" FOREIGN KEY ("EST_STR_ID")
	  REFERENCES  "QLTTB_STATUS_REGISTRO" ("STR_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_USUARIO_RESOLUCAO" 
   (	"URE_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"URE_TX_LOGIN" VARCHAR2(255) NOT NULL ENABLE, 
	"URE_TX_SENHA" VARCHAR2(255) NOT NULL ENABLE, 
	"URE_NM" VARCHAR2(255) NOT NULL ENABLE, 
	"URE_STATUS" NUMBER(1,0) DEFAULT 1, 
	"URE_EMAIL" VARCHAR2(255) NOT NULL ENABLE, 
	 CONSTRAINT "QLTTB_USUARIO_RESOLUCAO_PK" PRIMARY KEY ("URE_ID") ENABLE, 
	 CONSTRAINT "QLTTB_USUARIO_RESOLUCAO_EMAIL" UNIQUE ("URE_EMAIL") ENABLE
   )
/
CREATE TABLE  "QLTTB_HIST_RESOLUCAO" 
   (	"HRE_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"HRE_REGISTRO_ID" NUMBER(19,0), 
	"HRE_TPE_ID" NUMBER(19,0), 
	"HRE_FLAG" NUMBER(1,0), 
	"HRE_URE_ID" NUMBER(19,0), 
	"HRE_DT_OPERACAO" TIMESTAMP (6), 
	 CONSTRAINT "QLTTB_HIST_RESOLUCAO_PK" PRIMARY KEY ("HRE_ID") ENABLE, 
	 CONSTRAINT "QLTTB_USUARIO_RESOLUCAO_FK1" FOREIGN KEY ("HRE_URE_ID")
	  REFERENCES  "QLTTB_USUARIO_RESOLUCAO" ("URE_ID") ENABLE, 
	 CONSTRAINT "QLTTB_TIPO_ENTIDADE_FK2" FOREIGN KEY ("HRE_TPE_ID")
	  REFERENCES  "QLTTB_TIPO_ENTIDADE" ("TPE_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_JURISDICAO" 
   (	"JUR_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"JUR_NM" VARCHAR2(100) NOT NULL ENABLE, 
	"JUR_DS" VARCHAR2(4000), 
	 CONSTRAINT "SYS_C004235" PRIMARY KEY ("JUR_ID") ENABLE, 
	 CONSTRAINT "SYS_C004236" UNIQUE ("JUR_NM") ENABLE
   )
/
CREATE TABLE  "QLTTB_ORGAO" 
   (	"ORG_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"ORG_NM" VARCHAR2(255) NOT NULL ENABLE, 
	"ORG_SG" VARCHAR2(20) NOT NULL ENABLE, 
	"ORG_JUR_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"ORG_TX_ENDERECO" VARCHAR2(4000), 
	"ORG_NM_REPRESENTANTE" VARCHAR2(100), 
	"ORG_TX_TELEFONE" VARCHAR2(100), 
	"ORG_MUN_CD" NUMBER(38,0), 
	"ORG_TX_CEP" VARCHAR2(8), 
	"ORG_UFD_CD" NUMBER(38,0), 
	"ORG_CARGO" VARCHAR2(80), 
	"ORG_CNPJ" VARCHAR2(25), 
	"ORG_EMAIL" VARCHAR2(512), 
	"ORG_TX_TELEFONE2" VARCHAR2(100), 
	 CONSTRAINT "SYS_C004390" PRIMARY KEY ("ORG_ID") ENABLE, 
	 CONSTRAINT "SYS_C004391" UNIQUE ("ORG_SG") ENABLE, 
	 CONSTRAINT "QLTTB_ORGAO_UK" UNIQUE ("ORG_NM") ENABLE, 
	 CONSTRAINT "QLTTB_ORGAO_UK1" UNIQUE ("ORG_CNPJ") ENABLE, 
	 CONSTRAINT "QLTTB_ORGAO_MUN_CDC" FOREIGN KEY ("ORG_MUN_CD")
	  REFERENCES  "GEOFT_MUNICIPIO" ("MUN_CD") ENABLE, 
	 CONSTRAINT "QLTTB_ORGAO_ORG_UFD_CDC" FOREIGN KEY ("ORG_UFD_CD")
	  REFERENCES  "GEOFT_UNIDADE_FEDERACAO" ("UFD_CD") ENABLE, 
	 CONSTRAINT "QLTTB_ORGAO_ORG_JUR_IDC" FOREIGN KEY ("ORG_JUR_ID")
	  REFERENCES  "QLTTB_JURISDICAO" ("JUR_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_ORGAO_ESTACAO" 
   (	"OES_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"OES_ORG_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"OES_EST_ID" NUMBER(19,0) NOT NULL ENABLE, 
	 CONSTRAINT "QLTTB_ORGAO_ESTACAO_PK" PRIMARY KEY ("OES_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_ORGAO_USINA" 
   (	"OUS_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"OUS_ORG_ID" NUMBER(19,0), 
	"OUS_USI_ID" NUMBER(19,0), 
	 CONSTRAINT "QLTTB_ORGAO_USINA_PK" PRIMARY KEY ("OUS_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_ORGAO_USUARIO" 
   (	"USE_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"USE_ORG_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"USE_SE" VARCHAR2(255), 
	 CONSTRAINT "QLTTB_ORGAO_USUARIO_PK" PRIMARY KEY ("USE_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_TECNICO" 
   (	"TEC_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"TEC_NM" VARCHAR2(100) NOT NULL ENABLE, 
	"TEC_EMAIL" VARCHAR2(512), 
	"TEC_TELEFONE" VARCHAR2(256), 
	"TEC_TELEFONE2" VARCHAR2(256), 
	 CONSTRAINT "TEC_PK" PRIMARY KEY ("TEC_ID") ENABLE, 
	 CONSTRAINT "QLTTB_TECNICO_EMAIL" UNIQUE ("TEC_EMAIL") ENABLE
   )
/
CREATE TABLE  "QLTTB_TECNICO_USINA" 
   (	"TUS_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"TUS_TEC_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"TUS_USI_ID" NUMBER(19,0) NOT NULL ENABLE, 
	 CONSTRAINT "TUS_PK" PRIMARY KEY ("TUS_ID") ENABLE, 
	 CONSTRAINT "TUS_TEC_FK" FOREIGN KEY ("TUS_TEC_ID")
	  REFERENCES  "QLTTB_TECNICO" ("TEC_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_TIPO_USINA" 
   (	"TPU_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"TPU_NM" VARCHAR2(100) NOT NULL ENABLE, 
	"TPU_DS" VARCHAR2(255), 
	 CONSTRAINT "TPU_PK" PRIMARY KEY ("TPU_ID") ENABLE
   )
/
CREATE TABLE  "QLTTB_USINA_LOCALIZACAO" 
   (	"USL_ID" NUMBER(19,0) NOT NULL ENABLE, 
	"USL_USI_ID" NUMBER(19,0), 
	"USL_MUN_CD" NUMBER(19,0), 
	"USL_UFD_CD" NUMBER(19,0), 
	"USL_RIO_CD" NUMBER(19,0), 
	 CONSTRAINT "QLTTB_USINA_LOCALIZACAO_PK" PRIMARY KEY ("USL_ID") ENABLE, 
	 CONSTRAINT "QLTTB_USINA_USL_UFD_CDC" FOREIGN KEY ("USL_UFD_CD")
	  REFERENCES  "GEOFT_UNIDADE_FEDERACAO" ("UFD_CD") ENABLE, 
	 CONSTRAINT "QLTTB_USINA_USL_IDC" FOREIGN KEY ("USL_USI_ID")
	  REFERENCES  "QLTTB_USINA" ("USI_ID") ENABLE, 
	 CONSTRAINT "QLTTB_USINA_USL_RIO_CDC" FOREIGN KEY ("USL_RIO_CD")
	  REFERENCES  "GEOFT_RIO" ("RIO_CD") ENABLE, 
	 CONSTRAINT "QLTTB_USINA_USL_MUN_CDC" FOREIGN KEY ("USL_MUN_CD")
	  REFERENCES  "GEOFT_MUNICIPIO" ("MUN_CD") ENABLE
   )
/

CREATE OR REPLACE FUNCTION  "MD5" (text in varchar2)
return varchar2 is
hash_value varchar2(32);
begin
    select lower(rawtohex(md5raw(text)))
    into hash_value
    from dual;
    return hash_value;
end;
/
 CREATE OR REPLACE FUNCTION  "MD5RAW" (text in varchar2)
return varchar2 is
hash_value varchar2(20);
begin
   hash_value := dbms_obfuscation_toolkit.md5 (input_string => text);
   return hash_value;
end;
/
 
CREATE UNIQUE INDEX  "HSYS_C0031825" ON  "GEOFT_DNAEE_BACIA" ("DNB_CD")
/
CREATE UNIQUE INDEX  "HSYS_C0031827" ON  "GEOFT_DNAEE_SUBBACIA" ("DNS_CD")
/
CREATE UNIQUE INDEX  "HSYS_C0031830" ON  "GEOFT_MUNICIPIO" ("MUN_CD")
/
CREATE UNIQUE INDEX  "HSYS_C0031833" ON  "GEOFT_PAIS" ("PAI_CD")
/
CREATE UNIQUE INDEX  "HSYS_C0031835" ON  "GEOFT_RIO" ("RIO_CD")
/
CREATE UNIQUE INDEX  "HSYS_C0031844" ON  "GEOFT_UNIDADE_FEDERACAO" ("UFD_CD")
/
CREATE UNIQUE INDEX  "HSYS_C0031851" ON  "HDRTB_SUBBACIA_RIO" ("SBR_ID")
/
CREATE UNIQUE INDEX  "QLTTB_CONTATO_PK" ON  "QLTTB_CONTATO" ("CON_ID")
/
CREATE UNIQUE INDEX  "QLTTB_CONTROLE_DOCUMENTO_PK" ON  "QLTTB_CONTROLE_DOCUMENTO" ("CDO_ID")
/
CREATE UNIQUE INDEX  "QLTTB_HIST_RESOLUCAO_PK" ON  "QLTTB_HIST_RESOLUCAO" ("HRE_ID")
/
CREATE UNIQUE INDEX  "QLTTB_ORGAO_ESTACAO_PK" ON  "QLTTB_ORGAO_ESTACAO" ("OES_ID")
/
CREATE UNIQUE INDEX  "QLTTB_ORGAO_UK" ON  "QLTTB_ORGAO" ("ORG_NM")
/
CREATE UNIQUE INDEX  "QLTTB_ORGAO_UK1" ON  "QLTTB_ORGAO" ("ORG_CNPJ")
/
CREATE UNIQUE INDEX  "QLTTB_ORGAO_USINA_PK" ON  "QLTTB_ORGAO_USINA" ("OUS_ID")
/
CREATE UNIQUE INDEX  "QLTTB_ORGAO_USUARIO_PK" ON  "QLTTB_ORGAO_USUARIO" ("USE_ID")
/
CREATE UNIQUE INDEX  "QLTTB_STR_PK" ON  "QLTTB_STATUS_REGISTRO" ("STR_ID")
/
CREATE UNIQUE INDEX  "QLTTB_TECNICO_EMAIL" ON  "QLTTB_TECNICO" ("TEC_EMAIL")
/
CREATE UNIQUE INDEX  "QLTTB_TIPO_CONTATO_PK" ON  "QLTTB_TIPO_CONTATO" ("TPC_ID")
/
CREATE UNIQUE INDEX  "QLTTB_TIPO_DOCUMENTO_PK" ON  "QLTTB_TIPO_DOCUMENTO" ("TPD_ID")
/
CREATE UNIQUE INDEX  "QLTTB_TIPO_ENTIDADE_PK" ON  "QLTTB_TIPO_ENTIDADE" ("TPE_ID")
/
CREATE UNIQUE INDEX  "QLTTB_TIPO_OPERACAO_PK" ON  "QLTTB_TIPO_OPERACAO" ("TPO_ID")
/
CREATE UNIQUE INDEX  "QLTTB_USINA_LOCALIZACAO_PK" ON  "QLTTB_USINA_LOCALIZACAO" ("USL_ID")
/
CREATE UNIQUE INDEX  "QLTTB_USINA_PK" ON  "QLTTB_USINA" ("USI_ID")
/
CREATE UNIQUE INDEX  "QLTTB_USUARIO_RESOLUCAO_EMAIL" ON  "QLTTB_USUARIO_RESOLUCAO" ("URE_EMAIL")
/
CREATE UNIQUE INDEX  "QLTTB_USUARIO_RESOLUCAO_PK" ON  "QLTTB_USUARIO_RESOLUCAO" ("URE_ID")
/
CREATE UNIQUE INDEX  "SYS_C004159" ON  "QLTTB_ESTACAO" ("EST_ID")
/
CREATE UNIQUE INDEX  "SYS_C004235" ON  "QLTTB_JURISDICAO" ("JUR_ID")
/
CREATE UNIQUE INDEX  "SYS_C004236" ON  "QLTTB_JURISDICAO" ("JUR_NM")
/
CREATE UNIQUE INDEX  "SYS_C004390" ON  "QLTTB_ORGAO" ("ORG_ID")
/
CREATE UNIQUE INDEX  "SYS_C004391" ON  "QLTTB_ORGAO" ("ORG_SG")
/
CREATE UNIQUE INDEX  "TEC_PK" ON  "QLTTB_TECNICO" ("TEC_ID")
/
CREATE UNIQUE INDEX  "TPU_PK" ON  "QLTTB_TIPO_USINA" ("TPU_ID")
/
CREATE UNIQUE INDEX  "TUS_PK" ON  "QLTTB_TECNICO_USINA" ("TUS_ID")
/

Rem No package found to generate DDL.
CREATE OR REPLACE PROCEDURE  "CRIAR_GERAL" 
authid CURRENT_USER

AS
   SQL_IMMEDIATE VARCHAR2(2000);
   SQL_COUNT numeric(12, 2);
   CURSOR A
   IS
   SELECT UPPER(t.TABLE_NAME) as nome,
      UPPER(t1.COLUMN_NAME) as coluna,
      USER
   FROM user_constraints t
   INNER JOIN user_cons_columns t1 on (t1.CONSTRAINT_NAME = t.CONSTRAINT_NAME)
   where t.constraint_type = 'P'
   AND t.OWNER = user
   and t.TABLE_NAME in (
   SELECT r.TABLE_NAME
   FROM user_constraints r
   INNER JOIN user_cons_columns r1 on (r1.CONSTRAINT_NAME = r.CONSTRAINT_NAME)
   LEFT OUTER join USER_TAB_COLUMNS r2 on (r2.table_name = r.TABLE_NAME AND R2.COLUMN_NAME = R1.COLUMN_NAME)
   where r.constraint_type = 'P'
   AND r.OWNER = user
   and r2.DATA_TYPE <> 'DATE'  
   and r.TABLE_NAME in (SELECT rr.TABLE_NAME
   FROM user_constraints rr
   INNER JOIN user_cons_columns rr1 on (rr1.CONSTRAINT_NAME = rr.CONSTRAINT_NAME)
   LEFT OUTER join USER_TAB_COLUMNS rr2 on (rr2.table_name = rr.TABLE_NAME AND Rr2.COLUMN_NAME = Rr1.COLUMN_NAME)
   where rr.constraint_type = 'P'
   AND rr.OWNER = user
   group by rr.TABLE_NAME
   having count(*) <= 1)
   group by r.TABLE_NAME having COUNT(*) = 1);
BEGIN
   FOR I IN A
   LOOP
      Select COUNT(*)
      INTO SQL_COUNT
      from user_objects
      where object_type = 'SEQUENCE'
      and UPPER(object_name) = 'SQ_'||I.NOME;
      IF (SQL_COUNT = 0)
      THEN
         SQL_IMMEDIATE := 'CREATE SEQUENCE '||USER||'.SQ_'||I.NOME;
         EXECUTE IMMEDIATE SQL_IMMEDIATE;
         DBMS_OUTPUT.put_line(SQL_IMMEDIATE);
      END if;
      SQL_IMMEDIATE := 'CREATE OR REPLACE TRIGGER '
      || USER||'.TGI'||I.NOME
      || ' BEFORE INSERT'|| ' ON '||USER||'.'||I.NOME
      || ' REFERENCING OLD AS OLD NEW AS NEW'
      || ' FOR EACH ROW'
      || ' BEGIN'
      || ' IF (:NEW.'||I.COLUNA||' IS NULL) THEN'
      || '   SELECT '||USER||'.SQ_'||I.NOME||'.NEXTVAL'
      || ' INTO :NEW.'||I.COLUNA
      || ' FROM DUAL;'
      || ' END IF;'
      || ' END TGI'||I.NOME||';';
     
    
     EXECUTE IMMEDIATE SQL_IMMEDIATE;
    
  
   END LOOP;
   EXCEPTION
        WHEN OTHERS THEN
        RAISE_APPLICATION_ERROR (-20001,
        SQL_IMMEDIATE ||SQLERRM, TRUE) ;
END CRIAR_GERAL;
/
 
 CREATE SEQUENCE   "QLTTB_CONTATO_SEQ"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_GEOFT_DNAEE_BACIA"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_GEOFT_DNAEE_SUBBACIA"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_GEOFT_MUNICIPIO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_GEOFT_PAIS"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_GEOFT_RIO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_GEOFT_UNIDADE_FEDERACAO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_HDRTB_SUBBACIA_RIO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_ESTACAO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_HIST_RESOLUCAO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 221 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_JURISDICAO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_ORGAO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 853 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_ORGAO_ESTACAO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_ORGAO_USINA"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1149 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_ORGAO_USUARIO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 688 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_STATUS_REGISTRO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_TABELA_HISTORICO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 11 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_TECNICO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 444 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_TECNICO_USINA"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1706 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_TIPO_USINA"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 63 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_USINA"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 1125 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_USINA_LOCALIZACAO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 261 CACHE 20 NOORDER  NOCYCLE
/
 CREATE SEQUENCE   "SQ_QLTTB_USUARIO_RESOLUCAO"  MINVALUE 1 MAXVALUE 999999999999999999999999999 INCREMENT BY 1 START WITH 101 CACHE 20 NOORDER  NOCYCLE
/

Rem No synonym found to generate DDL.
CREATE OR REPLACE TRIGGER  "TGIGEOFT_DNAEE_BACIA" BEFORE INSERT ON AD.GEOFT_DNAEE_BACIA REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.DNB_CD IS NULL) THEN   SELECT AD.SQ_GEOFT_DNAEE_BACIA.NEXTVAL INTO :NEW.DNB_CD FROM DUAL; END IF; END TGIGEOFT_DNAEE_BACIA;
/
ALTER TRIGGER  "TGIGEOFT_DNAEE_BACIA" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIGEOFT_DNAEE_SUBBACIA" BEFORE INSERT ON AD.GEOFT_DNAEE_SUBBACIA REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.DNS_CD IS NULL) THEN   SELECT AD.SQ_GEOFT_DNAEE_SUBBACIA.NEXTVAL INTO :NEW.DNS_CD FROM DUAL; END IF; END TGIGEOFT_DNAEE_SUBBACIA;
/
ALTER TRIGGER  "TGIGEOFT_DNAEE_SUBBACIA" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIGEOFT_MUNICIPIO" BEFORE INSERT ON AD.GEOFT_MUNICIPIO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.MUN_CD IS NULL) THEN   SELECT AD.SQ_GEOFT_MUNICIPIO.NEXTVAL INTO :NEW.MUN_CD FROM DUAL; END IF; END TGIGEOFT_MUNICIPIO;
/
ALTER TRIGGER  "TGIGEOFT_MUNICIPIO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIGEOFT_PAIS" BEFORE INSERT ON AD.GEOFT_PAIS REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.PAI_CD IS NULL) THEN   SELECT AD.SQ_GEOFT_PAIS.NEXTVAL INTO :NEW.PAI_CD FROM DUAL; END IF; END TGIGEOFT_PAIS;
/
ALTER TRIGGER  "TGIGEOFT_PAIS" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIGEOFT_RIO" BEFORE INSERT ON AD.GEOFT_RIO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.RIO_CD IS NULL) THEN   SELECT AD.SQ_GEOFT_RIO.NEXTVAL INTO :NEW.RIO_CD FROM DUAL; END IF; END TGIGEOFT_RIO;
/
ALTER TRIGGER  "TGIGEOFT_RIO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIGEOFT_UNIDADE_FEDERACAO" BEFORE INSERT ON AD.GEOFT_UNIDADE_FEDERACAO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.UFD_CD IS NULL) THEN   SELECT AD.SQ_GEOFT_UNIDADE_FEDERACAO.NEXTVAL INTO :NEW.UFD_CD FROM DUAL; END IF; END TGIGEOFT_UNIDADE_FEDERACAO;
/
ALTER TRIGGER  "TGIGEOFT_UNIDADE_FEDERACAO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIHDRTB_SUBBACIA_RIO" BEFORE INSERT ON AD.HDRTB_SUBBACIA_RIO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.SBR_ID IS NULL) THEN   SELECT AD.SQ_HDRTB_SUBBACIA_RIO.NEXTVAL INTO :NEW.SBR_ID FROM DUAL; END IF; END TGIHDRTB_SUBBACIA_RIO;
/
ALTER TRIGGER  "TGIHDRTB_SUBBACIA_RIO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_ESTACAO" BEFORE INSERT ON AD.QLTTB_ESTACAO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.EST_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_ESTACAO.NEXTVAL INTO :NEW.EST_ID FROM DUAL; END IF; END TGIQLTTB_ESTACAO;
/
ALTER TRIGGER  "TGIQLTTB_ESTACAO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_HIST_RESOLUCAO" BEFORE INSERT ON AD.QLTTB_HIST_RESOLUCAO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.HRE_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_HIST_RESOLUCAO.NEXTVAL INTO :NEW.HRE_ID FROM DUAL; END IF; END TGIQLTTB_HIST_RESOLUCAO;
/
ALTER TRIGGER  "TGIQLTTB_HIST_RESOLUCAO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_JURISDICAO" BEFORE INSERT ON AD.QLTTB_JURISDICAO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.JUR_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_JURISDICAO.NEXTVAL INTO :NEW.JUR_ID FROM DUAL; END IF; END TGIQLTTB_JURISDICAO;
/
ALTER TRIGGER  "TGIQLTTB_JURISDICAO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_ORGAO" BEFORE INSERT ON AD.QLTTB_ORGAO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.ORG_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_ORGAO.NEXTVAL INTO :NEW.ORG_ID FROM DUAL; END IF; END TGIQLTTB_ORGAO;
/
ALTER TRIGGER  "TGIQLTTB_ORGAO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_ORGAO_ESTACAO" BEFORE INSERT ON AD.QLTTB_ORGAO_ESTACAO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.OES_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_ORGAO_ESTACAO.NEXTVAL INTO :NEW.OES_ID FROM DUAL; END IF; END TGIQLTTB_ORGAO_ESTACAO;
/
ALTER TRIGGER  "TGIQLTTB_ORGAO_ESTACAO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_ORGAO_USINA" BEFORE INSERT ON AD.QLTTB_ORGAO_USINA REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.OUS_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_ORGAO_USINA.NEXTVAL INTO :NEW.OUS_ID FROM DUAL; END IF; END TGIQLTTB_ORGAO_USINA;
/
ALTER TRIGGER  "TGIQLTTB_ORGAO_USINA" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_ORGAO_USUARIO" BEFORE INSERT ON AD.QLTTB_ORGAO_USUARIO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.USE_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_ORGAO_USUARIO.NEXTVAL INTO :NEW.USE_ID FROM DUAL; END IF; END TGIQLTTB_ORGAO_USUARIO;
/
ALTER TRIGGER  "TGIQLTTB_ORGAO_USUARIO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_STATUS_REGISTRO" BEFORE INSERT ON AD.QLTTB_STATUS_REGISTRO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.STR_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_STATUS_REGISTRO.NEXTVAL INTO :NEW.STR_ID FROM DUAL; END IF; END TGIQLTTB_STATUS_REGISTRO;
/
ALTER TRIGGER  "TGIQLTTB_STATUS_REGISTRO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_TECNICO" BEFORE INSERT ON AD.QLTTB_TECNICO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.TEC_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_TECNICO.NEXTVAL INTO :NEW.TEC_ID FROM DUAL; END IF; END TGIQLTTB_TECNICO;
/
ALTER TRIGGER  "TGIQLTTB_TECNICO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_TECNICO_USINA" BEFORE INSERT ON AD.QLTTB_TECNICO_USINA REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.TUS_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_TECNICO_USINA.NEXTVAL INTO :NEW.TUS_ID FROM DUAL; END IF; END TGIQLTTB_TECNICO_USINA;
/
ALTER TRIGGER  "TGIQLTTB_TECNICO_USINA" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_TIPO_USINA" BEFORE INSERT ON AD.QLTTB_TIPO_USINA REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.TPU_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_TIPO_USINA.NEXTVAL INTO :NEW.TPU_ID FROM DUAL; END IF; END TGIQLTTB_TIPO_USINA;
/
ALTER TRIGGER  "TGIQLTTB_TIPO_USINA" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_USINA" BEFORE INSERT ON AD.QLTTB_USINA REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.USI_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_USINA.NEXTVAL INTO :NEW.USI_ID FROM DUAL; END IF; END TGIQLTTB_USINA;
/
ALTER TRIGGER  "TGIQLTTB_USINA" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_USINA_LOCALIZACAO" BEFORE INSERT ON AD.QLTTB_USINA_LOCALIZACAO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.USL_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_USINA_LOCALIZACAO.NEXTVAL INTO :NEW.USL_ID FROM DUAL; END IF; END TGIQLTTB_USINA_LOCALIZACAO;
/
ALTER TRIGGER  "TGIQLTTB_USINA_LOCALIZACAO" ENABLE
/
CREATE OR REPLACE TRIGGER  "TGIQLTTB_USUARIO_RESOLUCAO" BEFORE INSERT ON AD.QLTTB_USUARIO_RESOLUCAO REFERENCING OLD AS OLD NEW AS NEW FOR EACH ROW BEGIN IF (:NEW.URE_ID IS NULL) THEN   SELECT AD.SQ_QLTTB_USUARIO_RESOLUCAO.NEXTVAL INTO :NEW.URE_ID FROM DUAL; END IF; END TGIQLTTB_USUARIO_RESOLUCAO;
/
ALTER TRIGGER  "TGIQLTTB_USUARIO_RESOLUCAO" ENABLE

